import { trans } from '@utils/common'
import { post, get, postL, getL } from '@utils/http'
import { SERVE_URL } from '@utils/config'

export default {
    apis: {
        //=================商户资金================
        FUND_LIST: SERVE_URL + 'apiExp/wealth/accountBalance/pageQuery', //商户余额列表
        FUND_LIST_BILL: SERVE_URL + 'apiExp/wealth/accountBalance/detail', //商户余额明细
        FUND_CURRENT: SERVE_URL + 'apiExp/manager/accountFund/curAccountFund',
        FUND_TYPES: SERVE_URL + 'apiExp/manager/accountFundBalance/listOrderBalanceBizType',
        FUND_NEW_TYPES: SERVE_URL + 'apiExp/manager/accountFundBalance/listOrderBalanceNewBizType',

        //==================流水===============
        BILL_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/pageOrderBalance',
        BILL_EXPORT: SERVE_URL + 'apiExp/wealth/merchantFundBalance/export',

        //=================提现==商户=============
        WITHDRAW_ACCOUNT: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/get', //获取账户信息
        WITHDRAW_ACCOUNT_SAVE: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/update', //修改提现账户信息
        WITHDRAW_APPLY: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/save', //提现

        WITHDRAW_STATUS: SERVE_URL + 'apiExp/manager/accountFundWithdraw/listWithdrawRecordStatus',
        WITHDRAW_LIST: SERVE_URL + 'apiExp/manager/accountFundWithdraw/pageWithdrawRecord',

        WITHDRAW_REVOKE: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/cancel',
        //=================提现=平台=================
        WITHDRAW_APPLY_LIST: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/pageQuery', //提现申请列表
        WITHDRAW_AUDIT: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/audit', //提现申请审核
        WITHDRAW_REMIT: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/toPay', //打款
        WITHDRAW_DETAIL: SERVE_URL + 'apiExp/wealth/accountFundWithdraw/detail', //详情

        //================财务-财务数据===========
        FASHIONABLE_LIST: SERVE_URL + 'apiExp/wealth/accountFundBalance/pageQuery',
        FASHIONABLE_LIST_COM: SERVE_URL + 'apiExp/wealth/merchantFundBalance/pageQuery',
        EXPORT_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/exportFashionable',

        NOT_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/getNotFashionable',
        NOT_EXPORT_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/exportNotFashionable',

        DEPOSIT_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountDepositBalance/page',
        DEPOSIT_EXPORT_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountDepositBalance/export',

        REFUND_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/getRefund',
        REFUND_EXPORT_FASHIONABLE_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/exportRefund',

        LEDGER_DATA_LIST: SERVE_URL + 'apiExp/manager/accountFundBalance/LedgerData',

        //================财务-资金流水===========
        COMPAMY_LIST: SERVE_URL + 'apiExp/manager/accountStatics/getCompamyLable',
        EXPORT_COMPAMY_LIST: SERVE_URL + 'apiExp/manager/accountStatics/exportCompamyLable',
        //================风控余额===================
        PAGE_RISK_FUND: SERVE_URL + 'apiExp/risk/pageRiskAccountFund',
        TOP_UP_RISK: SERVE_URL + 'apiExp/risk/riskAccountFundBalance/topUpRisk',
    },

    async getCompamyLableExport(param) {
        const res = await trans(
            postL(this.apis.EXPORT_COMPAMY_LIST, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async fashionableExport(param) {
        const res = await trans(
            postL(this.apis.EXPORT_FASHIONABLE_LIST, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async notFashionableExport(param) {
        const res = await trans(
            postL(this.apis.NOT_EXPORT_FASHIONABLE_LIST, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async notFashionable(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.NOT_FASHIONABLE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async accountFundBalanceExport(param) {
        const res = await trans(
            postL(SERVE_URL + 'apiExp/wealth/accountFundBalance/export', param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async depositFashionable(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.DEPOSIT_FASHIONABLE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async refundFashionableExport(param) {
        const res = await trans(
            postL(this.apis.REFUND_EXPORT_FASHIONABLE_LIST, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async refundFashionable(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.REFUND_FASHIONABLE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async ledgerDataList(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.LEDGER_DATA_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },
    async getCompamyLable(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.COMPAMY_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },
    async fashionable(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.FASHIONABLE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize, orderByColumn: 'createTime', orderDirection: 'desc' },
            })
        );
        return res.data;
    },
    async fashionableCom(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.FASHIONABLE_LIST_COM, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },
    async fund() {
        const res = await trans(get(this.apis.FUND_CURRENT));
        return res.data;
    },
    async types() {
        const res = await trans(post(this.apis.FUND_TYPES));
        return res.data;
    },

    async billExport(param) {
        const res = await trans(
            postL(this.apis.BILL_EXPORT, param, {
                responseType: 'blob',
            })
        );
        return res.data;
    },

    async newTypes() {
        const res = await trans(post(this.apis.FUND_NEW_TYPES));
        return res.data;
    },
    async funds(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.FUND_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
    async fundBills(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.FUND_LIST_BILL, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },
    async bills(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.BILL_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async withdrawAccount() {
        const res = await trans(get(this.apis.WITHDRAW_ACCOUNT));
        return res.data;
    },
    async withdrawAccountSave(param) {
        const res = await trans(postL(this.apis.WITHDRAW_ACCOUNT_SAVE, param));
        return res.success;
    },
    async withdraw(amount) {
        const res = await trans(getL(this.apis.WITHDRAW_APPLY, { amount }));
        return res.success;
    },

    async withdrawStatuss() {
        const res = await trans(post(this.apis.WITHDRAW_STATUS));
        return res.data;
    },
    async withdrawList(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.WITHDRAW_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },
    async withdrawRevoke(withdrawRecordId) {
        const res = await trans(getL(this.apis.WITHDRAW_REVOKE, { withdrawRecordId }));
        return res.success;
    },
    async withdrawDetail(withdrawRecordId) {
        const res = await trans(getL(this.apis.WITHDRAW_DETAIL, { withdrawRecordId }));
        return res.data;
    },

    async withdrawApplyList(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.WITHDRAW_APPLY_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    async withdrawAudit(param) {
        const res = await trans(postL(this.apis.WITHDRAW_AUDIT, param));
        return res.success;
    },

    async withdrawRemit(param) {
        const res = await trans(postL(this.apis.WITHDRAW_REMIT, param));
        return res.success;
    },
    async pageRiskFund(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.PAGE_RISK_FUND, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },
    async topUpRisk(param) {
        const res = await trans(postL(this.apis.TOP_UP_RISK, param));
        return res.success;
    },
};
